import requests
import hashlib
# pip install pyexecjs
import execjs

with open("parse.js", "r", encoding="utf8") as f:
	content = f.read()
	js_code = execjs.compile(content)

	payload = {
		"sort": 1,
		"start": 80,
		"limit": 20
	}

	payload_str = js_code.call("get_payload", payload)
	_p = js_code.call("get_p")
	sig = hashlib.md5(f"{payload_str}{_p}".encode()).hexdigest().upper()

	data = {
	    "payload": payload_str,
	    "sig": sig,
	    "v": 1
	}
	res = requests.post("https://www.xiniudata.com/api2/service/x_service/person_industry_list/list_industries_by_sort",json=data)

	data = res.json()
	result = js_code.call("get_data", data['d'])
	for item in result['list']:
		print(item)


# 处理错误
# AttributeError: 'NoneType' object has no attribute 'replace'
# UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 208: illegal multibyte sequence
# C:\Program Files\Python311\Lib\subprocess.py
# Popen   814行左右 把encoding=None  修改为 encoding="utf8",